﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Facebook;
using FacebookLoginButton.Models;
using Newtonsoft.Json;

namespace FacebookLoginButton.Controllers
{
    public class FriendsController : Controller
    {
        public ActionResult Index()
        {
            FacebookFriendsModel friends = new FacebookFriendsModel();

            var client = new FacebookClient(Session["accessToken"].ToString());
            dynamic fbresult = client.Get("me/friends");
            var data = fbresult["data"].ToString();

            friends.friendsListing = JsonConvert.DeserializeObject<List<FacebookFriend>>(data);

            return View(friends);
        }

    }
}